<html>
<head>
	<title>Conversion Table Initialization</title>
</head>
<body>
	<?php
		/*This script creates the Conversion table and inserts data into it*/
		
		//Database login info
		include_once("../submit/pword.php");
		
		//Connect to the database
		mysql_connect("$server", "$username", "$password") or die(mysql_error());
		mysql_select_db("cs1630History") or die(mysql_error());
		
		//Drop the table if a current one exists
		$result = mysql_query("DROP TABLE IF EXISTS Conversions") or die(mysql_error());
		
		//Create the table
		$result = mysql_query(
					"CREATE TABLE Conversions (
						_ID int primary key not null auto_increment,
						unit_name char(35) not null,
						to_unit char(35) not null,
						conversion_factor float not null,
						additional_factor int default 0 not null)") or die(mysql_error());
		
		//Insert the conversions (just add what conversions you need for now)
		$result = mysql_query(
					"INSERT INTO Conversions VALUES(
						NULL,
						'square miles', 
						'acres',
						640,
						0)") 
					or die(mysql_error());
		$result = mysql_query(
					"INSERT INTO Conversions VALUES(
						NULL,
						'acres', 
						'square miles',
						0.0015625,
						0)") 
					or die(mysql_error());
		//Close
		mysql_close();
	?>
		
</body>
</html>